package cn.smile.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 毛苏宇
 * User: me
 * Date: 2021/4/22
 * Time: 13:25
 * Description:
 */
@Controller
public class TestController {

    @GetMapping("/404")
    public String exceptionHandler(){
        return "/404";
    }

    @GetMapping("/language")
    @ResponseBody()
    public String root(){
        return "中文";
    }

    @GetMapping("/index")
    public String index(){
        return "/index";
    }

    @GetMapping("/notFound")
    @ResponseBody()
    public String notFound(){
        return "NotFound";
    }

    @GetMapping("/notFound2")
    @ResponseBody()
    public String notFound2(){
        return "未找到页面";
    }

    /**
     * 重定向
     * @return
     */
    @GetMapping("/ok")
    public String ok(){
        //重定向到/index
        return "redirect:/index";
    }

    /**
     * 转发
     * @return
     */
    @GetMapping("/error")
    public String error(){
        //转发到/language
        return "forward:/language";
    }


}
